/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2023.
 * Description: watchdog enhance feature
 * Author: Lai Hangliang
 * Create: 2023-10-11
 */

#ifndef _WATCHDOG_ENHANCE_H
#define _WATCHDOG_ENHANCE_H
#include <linux/types.h>
#include <linux/sysctl.h>
#include <linux/mutex.h>

#ifdef CONFIG_EULEROS_WATCHDOG_ENHANCE_FEATRUE
extern struct mutex watchdog_mutex;
extern int watchdog_enhance_enable;
extern int watchdog_print_period;
extern int watchdog_softlockup_divide;

DECLARE_PER_CPU(unsigned long, watchdog_touch_ts);

extern uint64_t watchdog_enhance_get_sample_period(void);
extern void set_sample_period(void);
extern void watchdog_process_before_softlockup(unsigned long touch_ts);
extern int get_softlockup_thresh(void);
extern uint64_t watchdog_set_sample_period(uint64_t sample_period);
extern unsigned long get_timestamp(void);
extern void update_wdt_last_arrival_ts(void);
extern int proc_watchdog_softlockup_divide(struct ctl_table *table, int write,
					   void __user *buffer, size_t *lenp, loff_t *ppos);
extern int proc_watchdog_enhance_enable(struct ctl_table *table, int write,
				void __user *buffer, size_t *lenp, loff_t *ppos);
extern void watchdog_touch_in_softlockup_check(struct pt_regs *regs);
#else
static inline void watchdog_touch_in_softlockup_check(struct pt_regs *regs) {};
static inline void watchdog_process_before_softlockup(unsigned long touch_ts) {};
static inline void update_wdt_last_arrival_ts(void) {};
static inline uint64_t watchdog_set_sample_period(uint64_t sample_period)
{
	return sample_period;
}
#endif /* CONFIG_EULEROS_WATCHDOG_ENHANCE_FEATRUE */

#endif /* _WATCHDOG_ENHANCE_H */
